package ModelImplementation

import (
	"PaySalary/Model"
	"time"
)

type MonthlySchedule struct {
	Model.PaymentSchedule
}

func IsLastDayOfMonth(date time.Time) bool {
	m1 := date.Month()
	m2 := date.AddDate(0,0,1).Month()

	return m1 != m2
}

func (m MonthlySchedule)MIsPaydate(payDate time.Time) bool {
	return IsLastDayOfMonth(payDate)
}

func (m MonthlySchedule)MGetPayPeriodStartDate( payPeriodEndDate time.Time) time.Time {
	lastDayOfMonth := payPeriodEndDate.Day()
	firstDayOfMonth := payPeriodEndDate.AddDate(0,0,-(lastDayOfMonth -1))
	return firstDayOfMonth
}
